import json
from configparser import ConfigParser

cfg = ConfigParser()
res = cfg.read('mysql.ini')

d1 = {}
for section,vlue in cfg.items():
    d2 = {}
    for k,v in cfg.items(section):
        d2[k] = v
    d1[section] = d2
#print({section:{k:v for k,v in cfg.items(section)} for section,vlue in cfg.items()})

with open('json','w') as f:
    json.dump(d1,f)


# 做的不错
